package cn.tedu.csmall.product.schedule;

import cn.tedu.csmall.product.repo.impl.AttributeRedisRepositoryImpl;
import cn.tedu.csmall.product.repo.impl.BrandRedisRepositoryImpl;
import cn.tedu.csmall.product.service.impl.AttributeServiceImpl;
import cn.tedu.csmall.product.service.impl.BrandServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务类
 */
@Slf4j
@Component
public class CacheSchedule {
    @Autowired
    BrandServiceImpl brandService;
    @Autowired
    AttributeServiceImpl attributeService;

    public CacheSchedule() {
        log.debug("创建计划任务对象：CacheSchedule");
    }

    @Scheduled(fixedRate = 5*60*1000)
    public void timer() {
        log.debug("执行了计划任务…………");
        brandService.rebuildCache();
        attributeService.rebuildCache();
    }
}
